package com.xbh.management.controller;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xbh.common.web.core.Result;
import com.xbh.management.model.ManLoginLog;
import com.xbh.management.service.ManLoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: management-center
 * @description:
 * @author: 许宝华
 * @create: 2021-12-13 17:19
 */

@RestController
@RequestMapping("/log")
public class ManLoginLogController {

    @Autowired
    private ManLoginLogService manLoginLogService;

    @PostMapping("/list")
    public Result list(@RequestBody JSONObject params){
        Integer pageNum = params.getInteger("pageNum");
        Integer pageSize = params.getInteger("pageSize");
        LambdaQueryWrapper<ManLoginLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(ManLoginLog::getUserId,params.getLong("userId"));
        wrapper.orderByDesc(ManLoginLog::getCreateTime);
        Page<ManLoginLog> page = manLoginLogService.page(new Page<ManLoginLog>(pageNum, pageSize), wrapper);
        return Result.success(page);
    }
}
